<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Insert title here</title>
        <jsp:include page="/view/taglib.jsp"></jsp:include>
    </head>
    <body>
        <div class="easyui-layout" data-options="fit:true">
            <div data-options="region:'north',split:true,border:false" style="height:80px;">
                <form id="searchForm">
                    <table>
                        <tr>
                            <td><a id="btn_add" class="easyui-linkbutton" data-options="group:'g1',iconCls:'icon-add'">添加</a></td>
                            <td><a id="btn_dele" class="easyui-linkbutton" data-options="group:'g1',iconCls:'icon-remove'">删除</a></td>
                            <td><a onclick="grid.datagrid('reload');" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'ext-icon-arrow_refresh'">刷新</a></td>
                        </tr>
                    </table>
                    <table>
                        <tr>
                            <td>用户名称</td>
                            <td><input name="user_nameSch" class="textbox" style="width: 120px; height: 22px;" /></td>
                            <td>创建时间</td>
                            <td><input name="createdStartSch" class="easyui-datebox" style="width: 100px" />
                                -
                                <input name="createdEndSch" class="easyui-datebox" style="width: 100px" />
                            </td>
                            <td><a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'ext-icon-zoom',plain:true" onclick="grid.datagrid('load',fw.serializeObject($('#searchForm')));">过滤</a> <a href="javascript:void(0);" id="reset_searchFilter" class="easyui-linkbutton" data-options="iconCls:'ext-icon-zoom_out',plain:true" onclick="$('#searchForm input').val('');grid.datagrid('load',{});">重置过滤</a></td>
                        </tr>
                    </table>
                </form>
            </div>
            <div data-options="region:'center',border:false">
                <table id="grid">
                </table>
            </div>
            <div data-options="region:'east',split:true,border:false" style="width: 50%; padding: 5px;">
                <form id="form" name="form" method="post" class="form">
                    <fieldset>
                        <legend> 基本信息--<span id="operateMode_title">添加模式</span> </legend>
                        <table class="table">
                            <tbody>
                                <tr style="display:none;">
                                    <th>id</th>
                                    <td><input id="id" readonly="readonly" name="id" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                <tr>
                                    <th>任务ID</th>
                                    <td><input id="taskId" value="0" name="taskId" class="textbox"   style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>任务状态</th>
                                    <td><input id="status" name="status" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>任务类型</th>
                                    <td><input id="taskType" name="taskType" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>职位</th>
                                    <td><input id="position" name="position" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>交通方式</th>
                                    <td><input id="transportation" name="transportation" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>

                                    <th>天气情况</th>
                                    <td><input id="weather" name="weather"  class="textbox"      style="height: 22px;"  /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>出发城市</th>
                                    <td><input id="departCity" name="departCity" class="textbox"  required = "required"    style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>到达城市</th>
                                    <td><input id="arriveCity" name="arriveCity" class="textbox"   required = "required"   style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>工单编号</th>
                                    <td><input id="taskNum" name="taskNum" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>错误类型</th>
                                    <td><input id="faultCategory" name="faultCategory" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>联系人姓名</th>
                                    <td><input id="contactName" name="contactName" class="textbox"   required = "required"   style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>联系人电话</th>
                                    <td><input id="contactPhone" name="contactPhone" class="textbox"   required = "required"   style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>标准收费</th>
                                    <td><input id="charge" name="charge" class="textbox"    required = "required"  style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>工时</th>
                                    <td><input id="workHours" name="workHours" class="textbox"  required = "required"    style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>省市</th>
                                    <td><input id="province" name="province" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>县市</th>
                                    <td><input id="country" name="country" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>固定电话</th>
                                    <td><input id="fixedPhone" name="fixedPhone" class="textbox"   required = "required"   style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>派单要求</th>
                                    <td><input id="sendDemand" name="sendDemand" class="textbox"  required = "required"    style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>故障原因</th>
                                    <td><input id="issueReason" name="issueReason" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>执行人</th>
                                    <td><input id="executorId"  name="executorId" class="textbox" required = "required"  style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>

                                    <th>真实工作时间</th>
                                    <td><input id="realWorkTime" name="realWorkTime" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <tr>

                                    <th>发布时间</th>
                                    <td><input id="sendTime" name="sendTime"  class="easyui-datebox" required = "required" style="width: 180px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>

                                    <th>真实到达时间</th>
                                    <td><input id="realArriveTime" name="realArriveTime"  class="easyui-datetimebox"  style="width: 180px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>

                                    <th>真实完成时间</th>
                                    <td><input id="realFinishTime" name="realFinishTime" class="easyui-datetimebox"  style="width: 180px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>

                                    <th>出发时间</th>
                                    <td><input id="departTime" name="departTime"  class="easyui-datetimebox" required = "required" style="width: 180px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>

                                    <th>到达时间</th>
                                    <td><input id="arriveTime" name="arriveTime"  class="easyui-datetimebox" required = "required" style="width: 180px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>用户评价</th>
                                    <td><input id="evaluation" name="evaluation" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>评价等级</th>
                                    <td><input id="rate" name="rate" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>服务记录</th>
                                    <td><input id="serviceRecord" name="serviceRecord" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>现场情况</th>
                                    <td><input id="liveSituation" name="liveSituation" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>处理结果</th>
                                    <td><input id="processResult" name="processResult" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>回访记录</th>
                                    <td><input id="visiteRecord" name="visiteRecord" class="textbox"      style="height: 22px;" /></td>
                                </tr>
                                
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>修改时间</th>
                                    <td><input id="editedTime" name="editedTime" data-options="disabled:true" class="easyui-datetimebox"  style="width: 180px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                                                                                                                                                <tr>
                                    <th>创建时间</th>
                                    <td><input id="createdTime" name="createdTime" data-options="disabled:true" class="easyui-datetimebox"  style="width: 180px;" /></td>
                                </tr>
                                                                                                                                                                                                                                                                <th>操作</th>
                                <td><a id="operateMode_submit" class="easyui-linkbutton" data-options="iconCls:'icon-save'">通过</a> <a id="operateMode_reset" class="easyui-linkbutton" data-options="iconCls:'icon-reload'">重置</a></td>
                                </tr>
                            </tbody>
                        </table>
                    </fieldset>
                </form>
            </div>
        </div>
        <script type="text/javascript">
        $("#id").attr("value", 1);
        $.getJSON(ctx+'listCSysClass.do',{parentIdSch:62 ,classtypeidSch:3 },function(parentsJson) {
            $("#status").combobox({
    			data:parentsJson.rows,
    			valueField:'text',
    	         textField:'text',
    	        selected:parentsJson.rows[0],
    	        filter: function(q, row){
            		var opts = $(this).combobox('options');
            		return row[opts.textField].indexOf(q) == 0;
            	}
    	})
 	});

        //任务类型
        $.getJSON(ctx+'listCSysClass.do',{parentIdSch:70 ,classtypeidSch:3 },function(parentsJson) {
            $("#taskType").combobox({
    			data:parentsJson.rows,
    			valueField:'text',
    	         textField:'text',
    	        selected:parentsJson.rows[0],
    	        filter: function(q, row){
            		var opts = $(this).combobox('options');
            		return row[opts.textField].indexOf(q) == 0;
            	}
    	})
    	});
        //交通方式
        $.getJSON(ctx+'listCSysClass.do',{parentIdSch:86 ,classtypeidSch:3 },function(parentsJson) {
            $("#transportation").combobox({
    			data:parentsJson.rows,
    			valueField:'text',
    	         textField:'text',
    	        selected:parentsJson.rows[0],
    	        filter: function(q, row){
            		var opts = $(this).combobox('options');
            		return row[opts.textField].indexOf(q) == 0;
            	}
    	})
    	});
      	//职务
        $.getJSON(ctx+'listCSysClass.do',{parentIdSch:83 ,classtypeidSch:3 },function(parentsJson) {
            $("#position").combobox({
    			data:parentsJson.rows,
    			valueField:'text',
    	         textField:'text',
    	        selected:parentsJson.rows[0],
    	        filter: function(q, row){
            		var opts = $(this).combobox('options');
            		return row[opts.textField].indexOf(q) == 0;
            	}
    	})
    	});
       //工程师&&人员列表
        $.getJSON(ctx+'listAllSUser.do',{},function(parentsJson) {
            $("#executorId").combobox({
    			data:parentsJson.rows,
    			valueField:'id',
    	         textField:'trueName',
    	        selected:parentsJson.rows[0],
    	        filter: function(q, row){
            		var opts = $(this).combobox('options');
            		return row[opts.textField].indexOf(q) == 0;
            	}
    	})
        });
        
        
        
            $(function() {
                var gird;
                grid=$('#grid').datagrid({
                    fit:true,
                    border : false,
                    collapsible : false,
                    rownumbers : true,
                    pagination : true,
                    singleSelect : true,
                    rownumbers : true,
                    url:ctx+'listSTaskSchedule.do?statusSch='+encodeURI(encodeURI("已回访")),
                    columns:[[
            		                       
            			{ sortable:true,field:'id',title:'id'}
            		                       
            			,{ sortable:true,field:'taskId',title:'任务ID'}
            		                       
            			,{ sortable:true,field:'status',title:'任务状态'}
            		                       
            			,{ sortable:true,field:'evaluation',title:'用户评价'}
            		                       
            			,{ sortable:true,field:'rate',title:'评价等级'}
            		                       
            			,{ sortable:true,field:'serviceRecord',title:'服务记录'}
            		                       

            			,{ sortable:true,field:'liveSituation',title:'现场记录'}
            		                       
            			,{ sortable:true,field:'processResult',title:'处理结果'}
            		                       
            			,{ sortable:true,field:'visiteRecord',title:'回访记录'}
            			

            			,{ sortable:true,field:'sendTime',title:'发布时间'}
	                       
            			,{ sortable:true,field:'realArriveTime',title:'实际到达时间'}
            		                       

            			,{ sortable:true,field:'realFinishTime',title:'实际结束时间'}
            			
            			,{ sortable:true,field:'departTime',title:'出发时间'}
	                       

            			,{ sortable:true,field:'arriveTime',title:'到达时间'}
                        
                        ,{ sortable:true,field:'departCity',title:'出发城市'}
                                           
                        ,{ sortable:true,field:'arriveCity',title:'到达城市'}
                        
            			,{ sortable:true,field:'weather',title:'天气情况'}
	                       

            			,{ sortable:true,field:'realWorkTime',title:'实际工作时间'}
            		                       
            			,{ sortable:true,field:'editedTime',title:'修改时间'}
            		                       
            			,{ sortable:true,field:'createdTime',title:'创建时间'}
            			
            			,{ sortable:true,field:'taskNum',title:'工单编号'}
                        
                        ,{ sortable:true,field:'taskType',title:'任务类型'}
                                           
                        ,{ sortable:true,field:'faultCategory',title:'错误类型'}
                                           
                        ,{ sortable:true,field:'contactName',title:'联系人姓名'}
                                           
                        ,{ sortable:true,field:'contactPosition',title:'联系人职位'}
                                           
                        ,{ sortable:true,field:'contactPhone',title:'联系人电话'}
                                           
                        ,{ sortable:true,field:'charge',title:'收费标准'}
                                           
                        ,{ sortable:true,field:'workHours',title:'工时'}
                                           
                        ,{ sortable:true,field:'transportation',title:'交通方式'}
                        
                        ,{ sortable:true,field:'province',title:'省市'}
                        
                        ,{ sortable:true,field:'country',title:'县市'}
                                           
                        ,{ sortable:true,field:'position',title:'职位'}
                                           
                        ,{ sortable:true,field:'fixedPhone',title:'固定电话'}
                                           
                        ,{ sortable:true,field:'sendDemand',title:'派单要求'}
                                           
                        ,{ sortable:true,field:'issueReason',title:'故障原因'}
                                           
                        ,{ sortable:true,field:'executorId',title:'执行人'}
            		                    ]],
                    onLoadSuccess : function(data) {
                        $('.iconImg').attr('src', fw.pixel_0);
                    },
                    onClickRow : function(index, row) {
                    	console.log(row);
                    	$("#form").form("reset");
                        $("#form").form("load", row);
                        $("#operateMode_title").html("修改模式");
                    }
                });
               
                //添加操作
                $("#btn_add").click(function() {
                    $("#operateMode_title").html("添加模式");
                    $('#grid').datagrid("unselectAll");
                    $("#id").attr("value", 0);
                    $("#form").form("reset");
                })
            
                //删除操作
                $("#btn_dele").click(function() {
                    var rows = $('#grid').datagrid('getSelections');
                    if (rows <= 0) {
                        $.messager.show({
                            title : message.title.normal,
                            msg : message.grid_select,
                            timeout : message.timeout,
                            showType : message.showType
                        });
                    } else {
                        $.messager.confirm(message.title.askTitle, message.dele_comfirm, function(r) {
                            if (r) {
                                var idValue = $("#form input[name='id']").val();
                                $.post(ctx+"delSTaskSchedule.do", {
                                    id : idValue
                                }, function(result) {
                                    if (result.success) {
                                        $.messager.show({
                                            title : message.title.normal,
                                            msg : message.dele_success,
                                            timeout : message.timeout,
                                            showType : message.showType
                                        });
                                        grid.datagrid('reload');
                                    } else {
                                        $.messager.show({
                                            title : message.title.normal,
                                            msg : message.dele_fail,
                                            timeout : message.timeout,
                                            showType : message.showType
                                        });
                                    }
                                }, 'json');
                                $("#btn_add").click();
                            }
                        });
                    }
                })
            
                
                
                //确认提交操作
                $("#operateMode_submit").click(function() {
                    var idValue = $("#form input[name='id']").val();
                    if ($('#form').form('validate')) {
                        if (idValue > 0) {
                            //修改
                            $.post(ctx+"updateSTaskSchedule.do", fw.serializeObject($('form')), function(result) {
                                if (result.success) {
                                    $.messager.show({
                                        title : message.title.normal,
                                        msg : message.update_success,
                                        timeout : message.timeout,
                                        showType : message.showType
                                    });
            
                                    grid.datagrid("reload");
            
                                    //重新获取form信息内容
                                    $("#form").form("load", ctx+"getSTaskScheduleById.do?id=" + idValue);
                                }
                            }, 'json');
                        } else {
                            if(idValue.trim().length == 0){
                                $.messager.show({
                                    title : message.title.normal,
                                    msg : message.add_button_click,
                                    timeout : message.timeout,
                                    showType : message.showType
                                });
                            }else{
                                //添加
                                $.post(ctx+"addSTaskSchedule.do", fw.serializeObject($('form')), function(result) {
                                    if (result.success) {
                                        $.messager.show({
                                            title : message.title.normal,
                                            msg : message.add_success,
                                            timeout : message.timeout,
                                            showType : message.showType
                                        });
                                        grid.datagrid("reload");
                                        $("#form").form("reset");
                                    }
                                }, 'json');
                            }
                        }
                    }
                })
                //重置操作
                $("#operateMode_reset").click(function() {
                    var idValue = $("#form input[name='id']").val();
                    if (idValue > 0) {
                        $("#form").form("load",ctx+"getSTaskScheduleById.do?id=" + idValue);
                    } else {
                        $("#form").form("reset");
                    }
                })
            });
        </script>
    </body>
</html>